<?xml version="1.0"?>

<xsl:stylesheet
  version="1.0"
  exclude-result-prefixes="doc"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
  xmlns:uri="http://xsltsl.org/uri"
>
  <xsl:include href="../uri.xsl"/>

  <doc:article>
    <doc:title>URI Module Test Suite</doc:title>
    <doc:para>This stylesheet tests the uri stylesheet module.</doc:para>
  </doc:article>

  <xsl:template name="uri">

    <xsl:message>URI tests starting</xsl:message>
    <xsl:text>&#10;&#10;Running uri tests&#10;&#10;</xsl:text>


    <xsl:message>Test uri:is-absolute-uri template</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:is-absolute-uri test</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:is-absolute-uri">
          <xsl:with-param name="uri" select="'scheme://authority/path?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'true'"/>
    </xsl:call-template>


    <xsl:message>Test uri:is-absolute-uri template (with relative URI)</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:is-absolute-uri test (with relative URI)</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:is-absolute-uri">
          <xsl:with-param name="uri" select="'path?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="''"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-scheme template</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-scheme test</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-scheme">
          <xsl:with-param name="uri" select="'scheme://authority/path?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'scheme'"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-scheme template (with no scheme)</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-scheme test (with no scheme)</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-scheme">
          <xsl:with-param name="uri" select="'path?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="''"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-authority template</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-authority test</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-authority">
          <xsl:with-param name="uri" select="'scheme://authority/path?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'authority'"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-authority template (with no scheme)</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-authority test (with no scheme)</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-authority">
          <xsl:with-param name="uri" select="'//authority/path?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'authority'"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-authority template (with no path, query, or fragment)</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-authority test (with no path, query, or fragment)</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-authority">
          <xsl:with-param name="uri" select="'scheme://authority'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'authority'"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-path template</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-path test</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-path">
          <xsl:with-param name="uri" select="'scheme://authority/path?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'/path'"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-path template (with no authority)</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-path test (with no authority)</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-path">
          <xsl:with-param name="uri" select="'scheme:/path?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'/path'"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-path template (with no scheme or authority)</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-path test (with no scheme or authority)</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-path">
          <xsl:with-param name="uri" select="'path?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'path'"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-path template (with no authority or '/')</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-path test (with no authority or '/')</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-path">
          <xsl:with-param name="uri" select="'scheme:path'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'path'"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-path template (with no path)</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-path test (with no path)</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-path">
          <xsl:with-param name="uri" select="'scheme://authority?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="''"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-query template</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-query test</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-query">
          <xsl:with-param name="uri" select="'scheme://authority/path?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'query'"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-query template (with no query)</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-query test (with no query)</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-query">
          <xsl:with-param name="uri" select="'scheme://authority/path#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="''"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-query template (with no fragment)</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-query test (with no fragment)</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-query">
          <xsl:with-param name="uri" select="'scheme://authority/path?query'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'query'"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-fragment template</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-fragment test</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-fragment">
          <xsl:with-param name="uri" select="'scheme://authority/path?query#fragment'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="'fragment'"/>
    </xsl:call-template>


    <xsl:message>Test uri:get-uri-fragment template (with no fragment)</xsl:message>

    <xsl:call-template name="test">
      <xsl:with-param name="description">uri:get-uri-fragment test (with no fragment)</xsl:with-param>
      <xsl:with-param name="result">
        <xsl:call-template name="uri:get-uri-fragment">
          <xsl:with-param name="uri" select="'scheme://authority/path?query'"/>
        </xsl:call-template>
      </xsl:with-param>
      <xsl:with-param name="expect" select="''"/>
    </xsl:call-template>

  </xsl:template>

</xsl:stylesheet>
